/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __INPUT_SYSTEM_H__
#define __INPUT_SYSTEM_H__

#include "Ogre.h"
#include <OIS/OIS.h>

namespace OgreCamNav
{
	class InputSystem
		: public OIS::KeyListener, public OIS::MouseListener
	{
	private:
		Ogre::RenderWindow *_win;
		OIS::InputManager *inputManager;
		OIS::Mouse  *mouse;
		OIS::Keyboard *keyboard;

		std::map<std::string, OIS::KeyListener*> keyListeners;
		std::map<std::string, OIS::MouseListener*> mouseListeners;

		InputSystem(void);
		~InputSystem(void);
	protected:
		bool keyPressed( const OIS::KeyEvent &e );
		bool keyReleased( const OIS::KeyEvent &e );

		bool mouseMoved( const OIS::MouseEvent &e );
		bool mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id );
		bool mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id );
	public:
		static InputSystem& getSingleton();
		void init(Ogre::RenderWindow* win);
		void capture();
		void setWindowExtents(int width,int height);

		void addKeyListener( OIS::KeyListener *keyListener, const std::string& instanceName );
		void addMouseListener( OIS::MouseListener *mouseListener, const std::string& instanceName );

		void removeKeyListener( const std::string& instanceName );
		void removeMouseListener( const std::string& instanceName );
	};
}
#endif
